Imports System 
Imports System.Text 
Imports System.Data
Imports System.Data.SqlClient
Imports System.Data.Common
Imports System.Collections
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Configuration 
Imports System.Xml 
Imports System.Xml.Serialization
Imports SubSonic 
Imports SubSonic.Utilities
Namespace Data
	''' <summary>
	''' Strongly-typed collection for the Announcements class.
	''' </summary>
	<Serializable> _
	Public Partial Class AnnouncementsCollection 
	Inherits ActiveList(Of Announcements, AnnouncementsCollection)
	    Public Sub New()
		End Sub
	End Class
	''' <summary>
	''' This is an ActiveRecord class which wraps the Announcements table.
	''' </summary>
	<Serializable> _
	Public Partial Class Announcements 
	Inherits ActiveRecord(Of Announcements)
		#Region ".ctors and Default Settings"
		
		Public Sub New()
			SetSQLProps()
			InitSetDefaults()
			MarkNew()
		End Sub
		
		Public Sub New(ByVal useDatabaseDefaults As Boolean)
			SetSQLProps()
			If useDatabaseDefaults = True Then
				ForceDefaults()
			End If
			MarkNew()
		End Sub
		Public Sub New(ByVal keyID As Object)
			SetSQLProps()
			InitSetDefaults()
			LoadByKey(keyID)
		End Sub
		Public Sub New(ByVal columnName As String, ByVal columnValue As Object)
			SetSQLProps()
			InitSetDefaults()
			LoadByParam(columnName,columnValue)
		End Sub
		Private Sub InitSetDefaults()
			SetDefaults()
		End Sub
		
		Protected Shared Sub SetSQLProps()
			GetTableSchema()
		End Sub
		#End Region
		
		#Region "Schema and Query Accessor"
		
		Public Shared ReadOnly Property Schema() As TableSchema.Table
			Get
				If BaseSchema Is Nothing Then
					SetSQLProps()
				End If
				Return BaseSchema
			End Get
		End Property
		Private Shared Sub GetTableSchema()
			If (Not IsSchemaInitialized) Then
				'Schema declaration
				Dim schema As TableSchema.Table = New TableSchema.Table("Announcements", TableType.Table, DataService.GetInstance("ClubStarterKitData"))
				schema.Columns = New TableSchema.TableColumnCollection()
				schema.SchemaName = "dbo"
				'columns
				
                
                Dim colvarId As TableSchema.TableColumn = New TableSchema.TableColumn(schema)
                colvarId.ColumnName = "id"
                colvarId.DataType = DbType.Int32
                colvarId.MaxLength = 0
                colvarId.AutoIncrement = true
                colvarId.IsNullable = false
                colvarId.IsPrimaryKey = true
                colvarId.IsForeignKey = false
                colvarId.IsReadOnly = false
                
                
                schema.Columns.Add(colvarId)
                
                Dim colvarItemdate As TableSchema.TableColumn = New TableSchema.TableColumn(schema)
                colvarItemdate.ColumnName = "itemdate"
                colvarItemdate.DataType = DbType.DateTime
                colvarItemdate.MaxLength = 0
                colvarItemdate.AutoIncrement = false
                colvarItemdate.IsNullable = false
                colvarItemdate.IsPrimaryKey = false
                colvarItemdate.IsForeignKey = false
                colvarItemdate.IsReadOnly = false
                
                
                schema.Columns.Add(colvarItemdate)
                
                Dim colvarTitle As TableSchema.TableColumn = New TableSchema.TableColumn(schema)
                colvarTitle.ColumnName = "title"
                colvarTitle.DataType = DbType.String
                colvarTitle.MaxLength = 500
                colvarTitle.AutoIncrement = false
                colvarTitle.IsNullable = false
                colvarTitle.IsPrimaryKey = false
                colvarTitle.IsForeignKey = false
                colvarTitle.IsReadOnly = false
                
                
                schema.Columns.Add(colvarTitle)
                
                Dim colvarDescription As TableSchema.TableColumn = New TableSchema.TableColumn(schema)
                colvarDescription.ColumnName = "description"
                colvarDescription.DataType = DbType.String
                colvarDescription.MaxLength = 8000
                colvarDescription.AutoIncrement = false
                colvarDescription.IsNullable = true
                colvarDescription.IsPrimaryKey = false
                colvarDescription.IsForeignKey = false
                colvarDescription.IsReadOnly = false
                
                
                schema.Columns.Add(colvarDescription)
                
                Dim colvarStaticURL As TableSchema.TableColumn = New TableSchema.TableColumn(schema)
                colvarStaticURL.ColumnName = "staticURL"
                colvarStaticURL.DataType = DbType.String
                colvarStaticURL.MaxLength = 8000
                colvarStaticURL.AutoIncrement = false
                colvarStaticURL.IsNullable = true
                colvarStaticURL.IsPrimaryKey = false
                colvarStaticURL.IsForeignKey = false
                colvarStaticURL.IsReadOnly = false
                
                
                schema.Columns.Add(colvarStaticURL)
                
                Dim colvarPhoto As TableSchema.TableColumn = New TableSchema.TableColumn(schema)
                colvarPhoto.ColumnName = "photo"
                colvarPhoto.DataType = DbType.Int32
                colvarPhoto.MaxLength = 0
                colvarPhoto.AutoIncrement = false
                colvarPhoto.IsNullable = false
                colvarPhoto.IsPrimaryKey = false
                colvarPhoto.IsForeignKey = false
                colvarPhoto.IsReadOnly = false
                
                
                schema.Columns.Add(colvarPhoto)
                
                Dim colvarAlbumid As TableSchema.TableColumn = New TableSchema.TableColumn(schema)
                colvarAlbumid.ColumnName = "albumid"
                colvarAlbumid.DataType = DbType.Int32
                colvarAlbumid.MaxLength = 0
                colvarAlbumid.AutoIncrement = false
                colvarAlbumid.IsNullable = true
                colvarAlbumid.IsPrimaryKey = false
                colvarAlbumid.IsForeignKey = false
                colvarAlbumid.IsReadOnly = false
                
                
                schema.Columns.Add(colvarAlbumid)
                
				BaseSchema = schema
				
				'add this schema to the provider
                'so we can query it later
                DataService.Providers("ClubStarterKitData").AddSchema("Announcements",schema)
			End If
		End Sub
		Public Shared Function CreateQuery() As Query
			Return New Query(Schema)
		End Function
		
		#End Region
		
		#Region "Props"
	
          
        <XmlAttribute("Id")> _
        Public Property Id As Integer 
			Get
				Return GetColumnValue(Of Integer)("id")
			End Get
		    
			Set
				SetColumnValue("id", Value)
			End Set
		End Property
		
		
		  
        <XmlAttribute("Itemdate")> _
        Public Property Itemdate As DateTime 
			Get
				Return GetColumnValue(Of DateTime)("itemdate")
			End Get
		    
			Set
				SetColumnValue("itemdate", Value)
			End Set
		End Property
		
		
		  
        <XmlAttribute("Title")> _
        Public Property Title As String 
			Get
				Return GetColumnValue(Of String)("title")
			End Get
		    
			Set
				SetColumnValue("title", Value)
			End Set
		End Property
		
		
		  
        <XmlAttribute("Description")> _
        Public Property Description As String 
			Get
				Return GetColumnValue(Of String)("description")
			End Get
		    
			Set
				SetColumnValue("description", Value)
			End Set
		End Property
		
		
		  
        <XmlAttribute("StaticURL")> _
        Public Property StaticURL As String 
			Get
				Return GetColumnValue(Of String)("staticURL")
			End Get
		    
			Set
				SetColumnValue("staticURL", Value)
			End Set
		End Property
		
		
		  
        <XmlAttribute("Photo")> _
        Public Property Photo As Integer 
			Get
				Return GetColumnValue(Of Integer)("photo")
			End Get
		    
			Set
				SetColumnValue("photo", Value)
			End Set
		End Property
		
		
		  
        <XmlAttribute("Albumid")> _
        Public Property Albumid As Nullable(Of Integer) 
			Get
				Return GetColumnValue(Of Nullable(Of Integer))("albumid")
			End Get
		    
			Set
				SetColumnValue("albumid", Value)
			End Set
		End Property
		
		
		
		
		#End Region
		
		
			    
	    
		
		
		
		
		
	    
	    'no foreign key tables defined (0)
	    
		
	    
	    'no ManyToMany tables defined (0)
	    
		
		#Region "ObjectDataSource support"
		
		''' <summary>
		''' Inserts a record, can be used with the Object Data Source
		''' </summary>
		Public Shared Sub Insert(ByVal varItemdate As DateTime,ByVal varTitle As String,ByVal varDescription As String,ByVal varStaticURL As String,ByVal varPhoto As Integer,ByVal varAlbumid As Nullable(Of Integer))
			Dim item As Announcements = New Announcements()
			
            item.Itemdate = varItemdate
            
            item.Title = varTitle
            
            item.Description = varDescription
            
            item.StaticURL = varStaticURL
            
            item.Photo = varPhoto
            
            item.Albumid = varAlbumid
            
			If Not System.Web.HttpContext.Current Is Nothing Then
				item.Save(System.Web.HttpContext.Current.User.Identity.Name)
			Else
				item.Save(System.Threading.Thread.CurrentPrincipal.Identity.Name)
			End If
		End Sub
		''' <summary>
		''' Updates a record, can be used with the Object Data Source
		''' </summary>
		Public Shared Sub Update(ByVal varId As Integer,ByVal varItemdate As DateTime,ByVal varTitle As String,ByVal varDescription As String,ByVal varStaticURL As String,ByVal varPhoto As Integer,ByVal varAlbumid As Nullable(Of Integer))
			Dim item As Announcements = New Announcements()
		    
                item.Id = varId
				
                item.Itemdate = varItemdate
				
                item.Title = varTitle
				
                item.Description = varDescription
				
                item.StaticURL = varStaticURL
				
                item.Photo = varPhoto
				
                item.Albumid = varAlbumid
				
			item.IsNew = False
			If Not System.Web.HttpContext.Current Is Nothing Then
				item.Save(System.Web.HttpContext.Current.User.Identity.Name)
			Else
				item.Save(System.Threading.Thread.CurrentPrincipal.Identity.Name)
			End If
		End Sub
		#End Region
		#Region "Columns Struct"
		Public Structure Columns
			Dim x as Integer
			
            Public Shared Id As String = "id"
            
            Public Shared Itemdate As String = "itemdate"
            
            Public Shared Title As String = "title"
            
            Public Shared Description As String = "description"
            
            Public Shared StaticURL As String = "staticURL"
            
            Public Shared Photo As String = "photo"
            
            Public Shared Albumid As String = "albumid"
            
		End Structure
		#End Region
	End Class
End Namespace
